package com.example.administrator.testdate;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    TextView tvShow,textCancle;
    ProgressDialog progressDialog;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tvShow = (TextView) findViewById(R.id.textView);
        textCancle = (TextView) findViewById(R.id.textView2);
        tvShow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                progressDialog=showProgressDialog("hello");
            }
        });
        textCancle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                cancleProgressDialog(progressDialog);
            }
        });

    }
    public ProgressDialog showProgressDialog(String msg) {
        ProgressDialog progressDialog = new MyProgressDialog(MainActivity.this, msg);
        progressDialog.setIndeterminate(true);// 设置进度条是否为不明确
        progressDialog.setCancelable(true);// 设置进度条是否可以按退回键取消
        progressDialog.show();
        return progressDialog;
        // return showProgressDialogNormal(msg);
    }
    public void cancleProgressDialog(ProgressDialog progressDialog) {
        if (progressDialog != null && progressDialog.isShowing()) {
            progressDialog.dismiss();
            progressDialog=null;
        }
    }

}
